<?php
/**
 * Default Template for Booking View
 */
defined('_JEXEC') or die('Restricted access');
$document = & JFactory::getDocument();
$document->addStyleSheet(JURI::base() . 'components/com_roombooking/assets/css/table.css');
$document->addScript(JURI::base() . 'components/com_roombooking/assets/js/jquery/jquery-1.5.2.min.js');
?>
<script type="text/javascript">
   jQuery.noConflict();
</script>
<style type="text/css">
    #graph{
        float: left;
    }
    #export-csv{
        display: block;
        height: 20px;
        line-height: 20px;
        font-size: 15px;
        font-weight: bold;
    }
</style>
<form id="filter" action="index.php" name="filter">
    <label>ユーザ：</label>
    <?php
    $this->item->id_user = JFactory::getUser()->id;
    echo JHTML::_('select.genericlist', $this->users, 'id_user', 'class=" inputbox"', 'id', 'name', $this->id_user);
    ?>
    
    <label>年：</label>
    <?php
    $mon = $this->year_by_user;
    $mons = split(',', $mon);
    $mons = array_reverse($mons);
    $arr = array(array('id' => '0', 'name' => '-- すべての年 --'));
    foreach ($mons as $month) {
        if($month != 0){
            $a_arr = array('id' => $month, 'name' => $month);
            $arr[] = $a_arr;
        }
    }

    echo JHTML::_('select.genericlist', $arr, 'year', 'class=" inputbox"', 'id', 'name', $this->active_year);
    ?>
    
    <label>月：</label>
    <?php
    $mon = $this->month_by_user;
    $mons = split(',', $mon);
    $mons = array_reverse($mons);
    $arr = array(array('id' => '0', 'name' => '-- すべての月 --'));
    foreach ($mons as $month) {
        if($month != 0){
            $a_arr = array('id' => $month, 'name' => $month);
            $arr[] = $a_arr;
        }
    }

    echo JHTML::_('select.genericlist', $arr, 'month', 'class=" inputbox"', 'id', 'name', $this->active_month);
    ?>
    <div class="componentheading"><?php echo JText::_('STATISTICS'); ?></div>
    <img id="graph" src="<?php echo JURI::base() ?>components/com_roombooking/views/statistics/tmpl/graph.php?_jpg_csimd=1&val=<?php echo $this->val; ?>&mon=<?php echo $this->mon; ?>" alt="graph" />

    <input type="hidden" name="option" value="com_roombooking" />
    <input id="view" type="hidden" name="view" value="csv" />
    <input id="csv-bt" type="submit" value="エクスポート CSV ファイル" />
</form>
<script type="text/javascript">
    var filter = jQuery('#filter');
    jQuery('#id_user,#month,#year').change(function(){
        jQuery('#view').val('statistics');
        if(jQuery('#year').val() == 0)jQuery('#month').val('0');
        filter.submit();
    });
    jQuery('#csv-bt').click(function(){
        filter.submit();
        return false;
    });
</script>